using System;

namespace Isis.Extensions
{
    public static class FuncExtensions
    {
        public static T SafeGetValue<T>(Func<T> func, T valueToReturn)
        {
            try
            {
                return func();
            }
            catch
            {
                return valueToReturn;
            }
        }

        public static T SafeGetValue<T>(Func<T> func)
        {
            return SafeGetValue(func, default(T));
        }
    }
}